package com.whcoding.multithreading.thred;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

/**
 * @program: spring-boot-learning
 * @description: 使用Callable 创建线程
 * @author: whcoding
 * @create: 2022-09-21 16:55
 **/
public class MyThreadCreateCallable {

	public static void main(String[] args) throws ExecutionException, InterruptedException {
		MyThreadCallable mc = new MyThreadCallable();
		FutureTask<Integer> ft = new FutureTask<>(mc);
		Thread thread = new Thread(ft);
		thread.start();
		System.out.println(ft.get());
	}


}

class MyThreadCallable implements Callable {
	@Override
	public String call() throws Exception {
		return "使用Callable 创建线程";
	}
}